import { useFlowStore } from "@/stores";
const flowStore = useFlowStore();

const TYPE = {
  ALL: 0,
  DISABLED: 2,
};

function formatFlowJson(result) {
  console.log("formatFlowJson", result);
  const flowDef = {};
  flowDef.flowWidgets = result.flowWidgets
    ? JSON.parse(result.flowWidgets)
    : [];
  const { id, name, icon, key, groupId, formKey, formId, describe } = result;
  flowDef.workFlowDef = {
    id,
    name,
    icon,
    key,
    groupId,
    formKey,
    formId,
    describe,
  };
  flowDef.nodeConfig = result.json;
  flowDef.flowPermission = result.flowPermission
    ? JSON.parse(result.flowPermission)
    : { type: 0 };
  console.log("flowDef", flowDef);
  flowStore.setFlowDef(flowDef);
}

export default {
  formatFlowJson,
};
